//
//  CPYHeaderViewCollectionViewCell.m
//  TTMusic
//
//  Created by chenpengyu on 16/4/1.
//  Copyright © 2016年 cpy. All rights reserved.
//

#import "CPYHeaderViewCollectionViewCell.h"

@interface CPYHeaderViewCollectionViewCell ()

@property (nonatomic, strong) TTMusicBaseLabel *nameLabel;


@end

@implementation CPYHeaderViewCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.nameLabel=[[TTMusicBaseLabel alloc] initWithFrame:CGRectMake(15 * FitWidth, 5, frame.size.width * 0.4, frame.size.height)];
        self.descLabel=[[TTMusicBaseLabel alloc] initWithFrame:CGRectMake(_nameLabel.frame.size.width + 15 * FitWidth, 0, 40 * FitWidth, frame.size.height)];
        [self addSubview:_descLabel];
        _descLabel.hidden = YES;
        _descLabel.font = [UIFont systemFontOfSize:13];

        _nameLabel.font = [UIFont systemFontOfSize:17];
        self.moreButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [_moreButton setTitleColor:COLOR(136, 136, 136) forState:UIControlStateNormal];
        _moreButton.frame = CGRectMake(350, 0, 50, 40);
        [_moreButton addTarget:self action:@selector(moreButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self updateFrame:_moreButton];
        [self addSubview:_nameLabel];
//        self.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_moreButton];
        UIView *splitLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SysWidth, 1)];
        splitLine.backgroundColor = COLOR(235, 235, 235);
        [self addSubview:splitLine];
        
        
    }
    return self;
}

- (void)updateFrame:(UIView *)view{
    
    CGRect rect = view.frame;
    view.frame = CGRectMake(rect.origin.x * FitWidth, rect.origin.y * FitWidth, rect.size.width * FitWidth, rect.size.height * FitWidth);
}
- (void)setDataModel:(CPYDiscoveryPageDataModel *)dataModel {
    _dataModel = dataModel;
    _nameLabel.text = dataModel.name;
}
- (void)moreButtonAction:(UIButton *)sender {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"MVJump" object:nil];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
